READ

Section: MINTLIB LIBRARY FUNCTIONS (3)
Updated: 3 March 1993
Index Return to Main Contents
 

NAME

read - read input  

SYNOPSIS

#include <unistd.h>

int read(int fd, void *buffer, unsigned int length);
 

DESCRIPTION

read attempts to read length bytes of data from the file referenced by the descriptor fd into the buffer pointed to by buffer. On objects capable of seeking, the read starts at a position given by the pointer associated with fd (see lseek). Upon return from read, the pointer is incremented by the number of bytes actually read. Objects that are not capable of seeking always read from the current position. The value of the pointer associated with such an object is undefined. Upon successful completion, read returns the number of bytes actually read and placed in the buffer. The system guarantees to read the number of bytes requested if the descriptor references a normal file which has that many bytes left before the EOF (end of file), but in no other case. If nbytes is not zero and read returns 0, then EOF has been reached. If the descriptor or the object is marked for non-blocking I/O, and less data are available than are requested by the read, only the data that are available are returned, and the count indicates how many bytes of data were actually read.  

RETURN VALUES

read returns the number of bytes actually read on success. On failure, it returns -1 and sets errno to indicate the error.  

SEE ALSO

dup(3), fcntl(3), ioctl(3), lseek(3), open(3), pipe(3)


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUES
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 11:14:55 GMT, June 22, 2025